﻿@model WebDocDB.Models.Database
<h4>New Collection</h4>
<hr />
@using (Ajax.BeginForm(new AjaxOptions() { OnSuccess = "DatabaseCreated", OnFailure = "DatabaseCreationError" }))
{
    @Html.AntiForgeryToken()    

    <div class="form-horizontal">
        <div class="form-group">
            @Html.Label("Database Name", htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-9">
                @Html.EditorFor(model => model.ID, new { htmlAttributes = new { @class = "form-control", style = "max-width: 100%" } })
                @Html.ValidationMessageFor(model => model.ID, "", new { @class = "text-danger" })
            </div>
            <div class=" col-md-offset-1"></div>
        </div>

        <div class="form-group">
            <div class="row">
                <div class="col-md-2">
                </div>
                <div class="col-md-9" style="text-align: right; padding-right:25px;">
                    <input type="submit" class="btn btn-primary btn-lg" value="Save" />
                </div>
                <div class="col-md-offset-1"></div>
            </div>
        </div>
    </div>
}

<script>
    function DatabaseCreated(result) {
        if (result.Success)
            refreshDatabases();
        else
            DatabaseCreationError(result.Message);
    }

    function DatabaseCreationError(data) {
        showError("ERROR! " + data.toString());
    }
</script>